package com.hzlx.service;

import com.hzlx.dao.dto.OrderPlacedEvent;
import com.hzlx.dto.OrderPlaceEvent;
import jakarta.annotation.Resource;
import org.springframework.context.event.EventListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class NotificationService {
    @Resource KafkaTemplate kafkaTemplate;
    @EventListener
    @Async
    public void sendMessage(OrderPlacedEvent event){
        kafkaTemplate.send("notTopic", new OrderPlaceEvent(event.getSource(),event.getOrderNumber()));
    }
}
